package com.erp.framework.util.mainmenu;

import java.sql.Connection;
import java.util.ArrayList;

import com.erp.framework.model.dao.ServiceLocator;
import com.erp.framework.util.logger.Logger;

public class MenuGroupDelegate implements java.io.Serializable {
    public MenuGroupDelegate() {
    }

    public ArrayList getMenuGroupList(String companyCode, String userId, String moduleName) {
        ArrayList menuGroupList = new ArrayList();
        Connection conn = null;
        try {
            conn = ServiceLocator.getInstance().getDSDBConnection();
            MenuGroupDAO dao = new MenuGroupDAO();
            menuGroupList = dao.getMenuGroupList(companyCode, userId, moduleName, conn);
        } catch (Exception e) {
            Logger.logExceptions(this, e);
        } finally {
            try {
                if (conn != null && !conn.isClosed())
                    conn.close();
            } catch (Exception e) {
            }
        }

        return menuGroupList;
    }
    
    public ArrayList getMenuGroupListByModule(String companyCode, String userId, String moduleName) {
        ArrayList menuGroupList = new ArrayList();
        Connection conn = null;
        try {
            conn = ServiceLocator.getInstance().getDSDBConnection();
            MenuGroupDAO dao = new MenuGroupDAO();
            menuGroupList = dao.getMenuGroupListByModule(companyCode, userId, moduleName, conn);
        } catch (Exception e) {
            Logger.logExceptions(this, e);
        } finally {
            try {
                if (conn != null && !conn.isClosed())
                    conn.close();
            } catch (Exception e) {
            }
        }

        return menuGroupList;
    }
    
    public ArrayList getAllMenuGroupList(String companyCode, String userId) {
        ArrayList menuGroupList = new ArrayList();
        Connection conn = null;
        try {
            conn = ServiceLocator.getInstance().getDSDBConnection();
            MenuGroupDAO dao = new MenuGroupDAO();
            menuGroupList = dao.getAllMenuGroupList(companyCode, userId, conn);
        } catch (Exception e) {
            Logger.logExceptions(this, e);
        } finally {
            try {
                if (conn != null && !conn.isClosed())
                    conn.close();
            } catch (Exception e) {
            }
        }

        return menuGroupList;
    }
        
}
